<?php
/**
 * best_seller_header sidebox - displays the first best selling product
*/

// test if box should display

$limit = " LIMIT 1";
$best_seller_query = "select distinct p.products_id, pd.products_name, p.products_price,p.products_image
                       from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                       where p.products_status = '1'
                       and p.products_ordered > 0
                       and p.products_id = pd.products_id
                       and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                       order by p.products_ordered desc, pd.products_name";
$best_seller_query .= $limit;

$best_sellers = $db->Execute($best_seller_query);
if ($best_sellers->RecordCount() ==1) {
	$module_sideboxes_primary_procuct['id'] = $best_sellers->fields['products_id'];
	$module_sideboxes_primary_procuct['name']  = $best_sellers->fields['products_name'];
	$module_sideboxes_primary_procuct['image']  = $best_sellers->fields['products_image'];
	$module_sideboxes_primary_procuct['price']  = $best_sellers->fields['products_price'];	
	require($template->get_template_dir('tpl_module_sideboxes_primary_product_header.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_module_sideboxes_primary_product_header.php');
}
?>